package com.example.Windturbine.Controller;

import com.example.Windturbine.Error.BusinessException;
import com.example.Windturbine.Response.CommonResult;
import com.example.Windturbine.Service.QaRobotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

/**
 * @Author 丁永新
 * @Date 2022/2/5
 */
@Slf4j
@Controller("qa")
@RequestMapping("/qa")
@CrossOrigin(allowCredentials = "true", allowedHeaders = "*")
public class QaRobotController {

    @Resource
    QaRobotService QaRobotService;


    /**
     * 查询问题
     * @param question
     * @param user_id
     * @return
     */
    @RequestMapping("/query")
    @ResponseBody
    public CommonResult getUserFunction(@RequestParam(name = "question") String question,@RequestParam(name = "id") Integer user_id){
        String reply=QaRobotService.query(question,user_id);
        return CommonResult.create(reply);
    }



}
